package com.button.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@ApiModel
public class PageResult<T> {

	public static <T> PageResult<T> getPage(long cur, long line, long total, List<T> records) {
        PageInfo pageInfo = new PageInfo(cur, line, total);
        PageResult<T> pageResult = new PageResult<>();

        pageResult.setItems(records);
        pageResult.setPage(pageInfo);

        return pageResult;
    }

    private List<T> items;

    private PageInfo page;

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    static class PageInfo {
        @ApiModelProperty(value = "当前页", example = "1")
        private long cur;
        @ApiModelProperty(value = "页面大小", example = "10")
        private long line;
        @ApiModelProperty(value = "总记录数", example = "20")
        private long total;
    }
}
